package org.example.day20240821;

import java.util.ArrayList;
import java.util.List;

public class Customer {
    private String name;
    private List<Record> recordList = new ArrayList<>();

    public Customer(String name) {
        this.name = name;
    }

    public void addRecord(Record record){
        recordList.add(record);
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBillInfo(){
        String result = "-----------------------\n";
        result += "租碟记录---"+this.name+"\n";
        double total_fee = 0;
        double total_score = 0;
        for(Record record : recordList){
            String movie_name = record.getMovie().getTitle();
            String movie_type = record.getMovie().getType();
            if(movie_type.equals("children")){
                double fee = 2;
                if(record.getRent_days() > 2){
                    fee+=(record.getRent_days()-2)*1.5;
                }
                total_fee += fee;
                total_score+=1;
                result += "\t\t" + movie_name + "\t" + fee + "\n";
            }
            else if(movie_type.equals("common")){
                double fee = 1.5;
                if(record.getRent_days() > 3){
                    fee+=(record.getRent_days()-3)*1.5;
                }
                total_fee += fee;
                total_score+=1;
                result += "\t\t" + movie_name + "\t" + fee + "\n";
            }
            else if(movie_type.equals("new_release")){
                double fee = 3 * record.getRent_days();
                result += "\t\t" + movie_name + "\t" + fee + "\n";
                total_fee += fee;
                total_score+=1;
                if(record.getRent_days()>1){
                    total_score+=1;
                }
            }
        }

        result+="共消费了 "+total_fee+" 元\n";
        result+="增加了 "+total_score+" 积分";
        return result;
    }
}